package shujia.day11;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/*
    TreeMap<String,String>

    TreeMap中的自然排序和比较器排序都是针对键来说的
 */
public class TreeMapDemo1 {
    public static void main(String[] args) {
        TreeMap<String, String> map1 = new TreeMap<>();
        map1.put("banana", "3");
        map1.put("apple", "4");
        map1.put("peach", "6");
        map1.put("apple", "3");
        map1.put("cherry", "19");

        Set<Map.Entry<String, String>> entries = map1.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "-" + value);
        }
    }
}
